//
//  UIButton+Extension.swift
//  Sinaweibotzw
//
//  Created by 檀志文 on 16/4/15.
//  Copyright © 2016年 ios檀志文. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(image: String, bkgImage: String = "timeline_card_bottom_background", title: String, fontSize: CGFloat = 12){
        self.init(frame: CGRectZero)
        // 按钮就创建完成了
        // 设置按钮背景图片
        setBackgroundImage(UIImage(named: bkgImage), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: "\(bkgImage)_highlighted"), forState: UIControlState.Highlighted)
//       设置按钮图片
        setImage(UIImage(named: image), forState: UIControlState.Normal)
        
//       设置按钮标题
        setTitle(title, forState: UIControlState.Normal)
    
//       设置文字大小和颜色
        setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
}
